<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <title>7-2 animations动画</title>
    <link rel="stylesheet" href="../common.css">
    <script src="../jquery-2.2.0.js"></script>
    <script src="../main.js"></script>
    <style>
        div{
            width:300px;
            height:240px;
            padding: 20px;
            margin: 20px 30px;
            border:2px solid black;
            display: inline-block;
            color: #fff;
            text-shadow: 1px 1px 2px black;
            font-family: 微软雅黑;
            font-weight: bold;
            background-color: red;
            vertical-align: top;
            /*white-space: pre-wrap;*/
            /*不写浏览器兼容的话谷歌和IE也可以，其他未测试*/
        }

        @keyframes colorChange {
            0%{
                background-color: red;
            }
            25%{
                background-color: yellow;
            }
            50%{
                background-color: green;
            }
            75%{
                background-color: blue;
            }
            100%{
                background-color: red;
            }
        }
        @keyframes colorChange2 {
            0%{
                background-color: red;
            }
            50%{
                background-color: yellow;
            }
            100%{
                background-color: green;
            }
        }

        #animations div:nth-of-type(1):hover{
            animation-name:colorChange;
            animation-duration: 3s;
            animation-timing-function: linear;
        }
        #animations div:nth-of-type(2):hover{
            animation-name:colorChange2;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-delay: 1500ms;
            animation-iteration-count: 3;
        }
        #animations div:nth-of-type(3):hover{
            animation-name:colorChange2;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
            animation-direction: alternate;
        }

        @keyframes mulAnimations {
            25%{
                background-color: yellow;
                transform: rotate(90deg) scale(1.2);
            }
            50%{
                background-color: green;
                transform: rotate(180deg) scale(1);
            }
            75%{
                background-color: blue;
                transform: rotate(270deg) scale(0.8);
            }
            100%{
                background-color: red;
                transform: rotate(360deg) scale(1);
            }
        }

        #mulAnimations div:nth-of-type(1){
            width: 240px;
            border-radius: 100% 100% 0;
            /*padding-bottom: 10px;*/
            /*transform-origin: bottom right;*/
        }
        #mulAnimations div:nth-of-type(1):hover{
            animation: mulAnimations 2s linear;
        }

        @keyframes pendulum {/*此例子本来想做成在25%，75%时稍微放大一点，
        但使用了transform后，不设置角度，浏览器会自动默认为0，而不是把缩放跟旋转分开进行，
        所以这个问题放到后面专题解决*/
            25%{
                background-color: orange;
                /*transform: scale(1.2);*/
            }
            50%{
                background-color: yellow;
                transform: rotate(-75deg);
            }
            75%{
                background-color: orange;
                /*transform: rotate(-45deg) ;*/

            }
            100%{
                background-color: red;
                transform: rotate(-15deg) ;
            }
        }

        #mulAnimations div:nth-of-type(2){
            position: relative;
            width: 240px;
            border-radius:0 0 0 100%;
            transform: rotate(-15deg);
            transform-origin: right top;
            left:-12%;
            /*transform-origin: bottom right;*/
        }
        #mulAnimations div:nth-of-type(2):hover{
            animation: pendulum 2s ease;
            animation-iteration-count: infinite;
        }

        @keyframes webEase {
            0%{
                opacity: 0;
                background-color: white;
            }
            100%{
                opacity: 1;
                background-color: white;
            }
        }
        #webEase div a{
            color: yellow;
        }
        body{
            animation-name: webEase;
            animation-duration: 1s;
            transition-timing-function: ease;
        }
    </style>
</head>
<body>
<h1>7-2 animations动画</h1>
<h3>animations动画</h3>
<section id="animations">
    <div>依次渐变到黄、绿、蓝、红色</div>
    <div>1500毫秒后，依次渐变到黄、绿色，连续3次</div>
    <div>依次渐变到黄、绿色，再是绿色、黄色、红色。这样一正一反连续交替循环</div>
</section>

<hr>
<h3>多个属性值同时改变的animations动画</h3>
<section id="mulAnimations">
    <div><br><br><br><br><br><br><br>颜色依次是黄、绿、蓝、红；大小依次是1.2,1，0.8，1；角度每次转360度</div>

    <div>这个单摆例子本来想做成在25%，75%时稍微放大一点，
        但使用了transform后，不设置角度，浏览器会自动默认为0，而不是把缩放跟旋转分开进行，
        所以这个问题放到后面专题解决。还有颜色变化也不知如何单独控制速度为linear</div>
</section>

<hr>
<h3>网页淡入效果</h3>
<section id="webEase">
    <div><a href="02animations.html">刷新本网页，能看到淡入效果</a></div>
    <div><a href="01Transitions.html">进入其他网页，则没有</a></div>
</section>

</body>
</html>